#include<stdio.h>
int main()
{
	int n=0;
 	while(scanf("%d",&n)!=EOF) {
 		int a=0,x=0;
 		if(n%3==1) x += 1;
 		while(n>2){
  			a = n/3;
 		 	x += a;
 			n = a+n%3;
 		}
		printf("%d\n",x);
 	}
 	return 0;
 }
